/*
 *  TimeControllerTester.cpp
 *  SoundController0002
 *
 *  Created by jiro on 11/02/23.
 *  Copyright 2011 jiro music. All rights reserved.
 *
 */

#include "TimeControllerTester.h"
#include "../TimeController.h"
#include "CustomAssert.h"

namespace sc 
{
	void TimeControllerTester::TestAll()
	{
		Test_GetNoteSeconds001();
		
		Test_GetNoteSeconds002();
		
	}
	
	void TimeControllerTester::Test_GetNoteSeconds001()
	{
		const double beatsPerMiniute = 60;
		const double beatNumerator = 4;
		const double beatFraction = 4;
		TimeController controller( beatsPerMiniute, beatNumerator, beatFraction );

		AssertEqual( controller.GetNoteSeconds( TimeController::QuarterNote ), 1 );
		AssertEqual( controller.GetNoteSeconds( TimeController::HalfNote ), 2 );
		AssertEqual( controller.GetNoteSeconds( TimeController::WholeNote ), 4 );
		AssertEqual( controller.GetNoteSeconds( TimeController::HalfNote, 3 ), 2.0 / 3.0 );
	}

	void TimeControllerTester::Test_GetNoteSeconds002()
	{
		const double beatsPerMiniute = 100;
		const double beatNumerator = 4;
		const double beatFraction = 4;
		TimeController controller( beatsPerMiniute, beatNumerator, beatFraction );

		AssertEqual( controller.GetNoteSeconds( TimeController::QuarterNote ), ( 60.0 / 100.0 ) );
		AssertEqual( controller.GetNoteSeconds( TimeController::HalfNote ), 2 * ( 60.0 / 100.0 ) );
		AssertEqual( controller.GetNoteSeconds( TimeController::WholeNote ), 4 * ( 60.0 / 100.0 ) );
		AssertEqualWithError( controller.GetNoteSeconds( TimeController::HalfNote, 3 ), ( 2.0 / 3.0 ) * ( 60.0 / 100.0 ), 0.0001 );
	}


}
